package com.itheima.appserver.controller;

import com.itheima.appserver.interceptor.UserThreadLocal;
import com.itheima.appserver.service.HuanXinService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * 环信相关API接口
 */
@RestController
@RequestMapping("huanxin")
public class HuanxinController {

    @Autowired
    private HuanXinService huanXinService;

    /**
     * 根据环信的用户名称查询环信的用户名称和密码
     *
     * @return
     */
    @GetMapping("user")
    public ResponseEntity queryHuanXinUser() {
        Map<String, String> huanXinUser = huanXinService.queryHuanXinUserByUserId(UserThreadLocal.getUserId());
        return ResponseEntity.ok(huanXinUser);
    }
}
